package com.chujian.framework.mybatis.tenant;

import lombok.extern.slf4j.Slf4j;

import java.util.HashSet;
import java.util.Set;

@Slf4j
public class LogicIgnoreAcTableHolder {

    private static final ThreadLocal<Set<String>> h = ThreadLocal.withInitial(HashSet::new);

    public static Set<String> getIgnoreTables() {
        return h.get();
    }

    public static synchronized void addIgnoreAcTable(String tableName, String why) {
        log.debug("++临时忽略表 {} 的ac条件,原因:{}", tableName, why);
        h.get().add(tableName);
    }

    public static synchronized void removeIgnoreAcTable(String tableName) {
        log.debug("--取消临时忽略表 {} 的ac条件", tableName);
        h.get().remove(tableName);
    }

}
